package com.asset.dispoal.extension.service.command;

import com.asset.dispoal.extension.domain.db.entity.RolePermissionDO;
import com.asset.dispoal.extension.domain.db.mapper.PermissionMapper;
import com.asset.dispoal.extension.domain.dto.RolePermissionDTO;
import com.asset.dispoal.extension.dto.PermissionRequest;
import com.asset.dispoal.extension.service.converter.PermissionConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommand;

import java.util.List;

@Component
public class PermissionRoleCommand implements BaseCommand<PermissionRequest, List<RolePermissionDTO>> {

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public List<RolePermissionDTO> execute(PermissionRequest permissionRequest) {
        List<RolePermissionDO> doList = permissionMapper.queryRolePermission(permissionRequest.getUserId(), permissionRequest.getAuthCode(), permissionRequest.getCarry());
        return PermissionConverter.INSTANCE.roleDOToDTOList(doList);
    }
}
